package com.keyware.utils.keycloud;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;

public class ReadFile {
	public static String readFile(String filePath,String encoding) throws Exception{
		FileInputStream fis = new FileInputStream(filePath);
		InputStreamReader isr = new InputStreamReader(fis,encoding);
		BufferedReader br = new BufferedReader(isr);
		String line = null;
		StringBuilder sb = new StringBuilder();
		while((line = br.readLine())!=null){
			sb.append(line);
		}
		br.close();
		isr.close();
		fis.close();
		String str = sb.toString();
		if(null!=str && str.length()>0){
			str = str.replaceAll("\r|\n", "");
		}
		return str;
	}
}
